package com.bt.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bt.mapper.DtsCouponMapper;
import com.bt.mapper.DtsCouponUserMapper;
import com.bt.mapper.DtsUserMapper;
import com.bt.pojo.DtsCouponUser;
import com.bt.service.DtsCouponUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wbt
 * @version v1.0
 * @project shop_manage
 * @data 2022/9/26 10:58
 **/
@Service
public class DtsCouponUserServiceImpl implements DtsCouponUserService {
    @Autowired
    private DtsCouponUserMapper dtsCouponUserMapper;
    @Override
    public IPage<DtsCouponUser> findDtsCouponUserByPage(Integer page, Integer limit, Integer couponId, Integer userId, Short status, String sort, String order) {
        return  dtsCouponUserMapper.selectPage(new Page<DtsCouponUser>(page,limit),new QueryWrapper<DtsCouponUser>().eq(couponId!=null?true:false,"coupon_id",couponId).eq(userId!=null?true:false,"user_id",userId).eq(status!=null?true:false,"status",status).orderBy(!StringUtils.isEmpty(order),"desc".equals(order),sort));
    }
}
